package top.gbiot.scan.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import lombok.Getter;
import top.gbiot.scan.entity.Device;

import java.util.ArrayList;
import java.util.List;

public class DeviceListener  extends AnalysisEventListener<Device> {

    @Getter
    private List<Device> deviceList = new ArrayList<Device>();

    public DeviceListener() {
        super();
        deviceList.clear();
    }

    /**
     * 每一条数据解析都会调用
     */
    @Override
    public void invoke(Device device, AnalysisContext context) {
        deviceList.add(device);
    }

    /**
     * 所有数据解析完成都会调用
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {

        for (Device device : deviceList) {
            System.out.println(device);
        }
       // createDevice.createTable();
        //studentList.forEach(System.out::println);

    }
}
